package com.atguigu.yygh.cmn.ExListener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.atguigu.yygh.cmn.mapper.DictMapper;
import com.atguigu.yygh.model.cmn.Dict;
import com.atguigu.yygh.vo.cmn.DictEeVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author DongYu Zhou
 * @date 2022/6/21 22:02
 */
@Component
public class ExLin extends AnalysisEventListener<DictEeVo> {
    @Autowired
    private DictMapper dictMapper;

    @Override
    public void invoke(DictEeVo dictEeVo, AnalysisContext analysisContext) {
        //1转化数据类型
        Dict dict = new Dict();
        BeanUtils.copyProperties(dictEeVo, dict);
        //2补充参数
        dict.setIsDeleted(0);
        //3数据入库
        dictMapper.insert(dict);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}

